import 'package:dmz/base/pageWidget/base_stateful_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class BottomBarWidget extends StatefulWidget {
  final int selectIndex;
  final Function itemClick;
  const BottomBarWidget(
      {super.key, this.selectIndex = 0, required this.itemClick});

  @override
  State<BottomBarWidget> createState() => _BottomBarWidgetState();
}

class _BottomBarWidgetState extends State<BottomBarWidget> {
  List<String> itemImages = [
    'assets/images/home/bar/home_select_true.png',
    'assets/images/home/bar/home_select_false.png',
    'assets/images/home/bar/find_select_true.png',
    'assets/images/home/bar/find_select_false.png',
    'assets/images/home/bar/mein_select_true.png',
    'assets/images/home/bar/mein_select_false.png'
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.only(
            left: 80.sp,
            right: 80.sp,
            bottom: MediaQuery.of(context).padding.bottom),
        height: 120.sp + MediaQuery.of(context).padding.bottom,
        color: const Color(0xFF32333D),
        child:
            Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
          barItem(0, widget.selectIndex == 0),
          barItem(1, widget.selectIndex == 1),
          barItem(2, widget.selectIndex == 2)
        ]));
  }

  Widget barItem(int index, bool isSelect) {
    int imageaIndex = index * 2 + (isSelect ? 0 : 1);
    return Image.asset(itemImages[imageaIndex], width: 80.sp, height: 80.sp)
        .addGestureDetector(() => widget.itemClick(index));
  }
}
